<?php

/*------------------------------------------------
*
*   Explay Engine Content Management System.
*   Copyright © 2008 Golovdinov Alexander.
*
*-------------------------------------------------
*
*   Official site: wwww.alex-home.spb.ru/explay.html
*   Contact e-mail: golovdinov@gmail.com
*
*   GNU General Public License original source:
*   http://www.gnu.org/licenses/gpl-3.0.html
*
------------------------------------------------*/


if (!defined ('EXPLAY')) exit;

//error_reporting (E_ALL);

past_path (array ( array('', 'Журнал ошибок') ));

if (isset($_GET['clear'])) {
	$file = fopen ($_SERVER['DOCUMENT_ROOT'].'/explaylogs/errorlog.txt', 'w+');
	fclose ($file);
	site_message ('Журнал ошибок очищен!');
}

include $_SERVER['DOCUMENT_ROOT'].'/engine/xml.class.php';

$log = new XML;

$log->xml_file = $_SERVER['DOCUMENT_ROOT'].'/explaylogs/errorlog.txt';
$log->cache_file();

$main_array = $log->select_array ('error');

if (count($main_array) == 0) site_message ('Нет записей в журнале ошибок!');
else {
	
	$out = "\n\n<style>._help_ {color:silver;}</style>\n\n";
	
	
	foreach ($main_array as $err) {
		$date = $log->select_from_text ('date', $err);
		$ip = $log->select_from_text ('ip', $err);
		$errno = $log->select_from_text ('errno', $err);
		$type = $log->select_from_text ('type', $err);
		$msg = $log->select_from_text ('msg', $err);
		$url = $log->select_from_text ('urlstring', $err);
		$script = $log->select_from_text ('script', $err);
		$line = $log->select_from_text ('line', $err);
	
		//$out .= $err."\r\n\r\n";
		$out .= "\r\n\t<tr><td>".
			"\r\n\t\t<table>".
			"\r\n\t\t<tr><td><br /><span class=\"_help_\">дата:</span></td><td><br />".$date."</td></tr>".
			"\r\n\t\t<tr><td><span class=\"_help_\">ip:</span></td><td>".$ip."</td></tr>".
			"\r\n\t\t<tr><td><span class=\"_help_\">номер:</span></td><td>".$errno."</td></tr>".
			"\r\n\t\t<tr><td><span class=\"_help_\">тип:</span></td><td>".$type."</td></tr>".
			"\r\n\t\t<tr><td valign=\"top\"><span class=\"_help_\">сообщение:</span></td><td>".$msg."</td></tr>".
			"\r\n\t\t<tr><td><span class=\"_help_\">адрес:</span></td><td>".$url."</td></tr>".
			"\r\n\t\t<tr><td><span class=\"_help_\">файл:</span></td><td>".$script."</td></tr>".
			"\r\n\t\t<tr><td><span class=\"_help_\">линия:</span></td><td>".$line."</td></tr>".
			"\r\n\t\t</table>".
			"\r\n\t</td></tr>";
		
	}
	
	past_table ('Журнал ошибок (<a href="admin.php?do=show_errorlog&clear=true">очистить</a>)', '<table class="body_table">'.$out.'</table>');
	
	
}


come_back ('панели администратора', 'admin.php');
